$createstring = sprintf(gettext("Change the connection named %s"), $provider);
}
else {
$createstring = sprintf(gettext("Create a connection named %s"), $provider);
}
}
SWITCH: for( $menu ) {
/^main/ && do {
# This section sets up the main menu.
@menuvar = (gettext("This is the PPP configuration utility. It does not connect to your isp: just configures ppp so that you can do so with a utility such as pon. It will ask for the username, password, and phone number that your ISP gave you. If your ISP uses PAP or CHAP, that is all you need. If you must use a chat script, you will need to know how your ISP prompts for your username and password. If you do not know what your ISP uses, try PAP. Use the up and down arrow keys to move around the menus. Hit ENTER to select an item. Use the TAB key to move from the menu to <OK> to <CANCEL> and back. To move on to the next menu go to <OK> and hit ENTER. To go back to the previous menu go to <CANCEL> and hit enter."),
gettext("Main Menu"), 5,
"Create", $createstring);
push @menuvar, "Change", gettext("Change a connection"),
"Delete", gettext("Delete a connection") unless $noname;
push @menuvar, "Finished", gettext("Finish and save files") if checkchanges("CHECK");
unshift @menuvar, "--nocancel";
last SWITCH;
};
/^method/ && do {
# menu of connection methods
my $authmethod = uc($$ispauth);
@menuvar = (sprintf(gettext("Please select the authentication method for this connection. PAP is the method most often used in Windows 95, so if your ISP supports the NT or Win95 dial up client, try PAP. The method is now set to %s."), $authmethod),
sprintf(gettext(" Authentication Method for %s"), $provider), 6,
"PAP", gettext("Peer Authentication Protocol"),
"Chat", gettext("Use \"chat\" for login:/password: authentication"),
@menuvar = (gettext("Please select the property you wish to modify, select \"Cancel\" to go back to start over, or select \"Finished\" to write out the changed files."),
sprintf(gettext("\"Properties of %s\""), $provider), 14,
#This menu allows you to change some of the more obscure settings. Select \
#the setting you wish to change, and select \"Previous\" when you are done. \
#Use the arrow keys to scroll the list."),
@menuvar = (gettext("This menu allows you to change some of the more obscure settings. Select the setting you wish to change, and select \"Previous\" when you are done. Use the arrow keys to scroll the list."),
sprintf(gettext("\"Advanced Settings for %s\""), $provider), 11,
push @menuvar, ( "Quit", gettext("Exit this utility"));
do { $action = menu @menuvar } while $action eq ' ' ;
# Put up the menu that we just constructed.
# ' ' means that a blank line has been selected, so just loop.
return "CANCEL" if ($result != 0); # He hit cancel: return to main menu.
return $action;
} # end of mkmenu
sub do_action() {
my $action;
my $menu = "main";
my @previous_action_stack;
my @previous_menu_stack = "main";
while (1) {
push @previous_menu_stack, $menu if $menu ne $previous_menu_stack[-1];
$action = mkmenu( $menu );
ACTION: for( $action ) {
/^Previous|^CANCEL/ && do {
pop @previous_menu_stack;
$menu = @previous_menu_stack ? pop @previous_menu_stack : "main";
last ACTION;
};
/^Properties/ && do {
$menu = "properties";
last ACTION;
};
/^Advanced/ && do {
$menu = "advanced";
last ACTION;
};
/^Method/ && do {
$menu = "method";
last ACTION;
};
/^Change/ && do {
$menu = changeConnection( $menu );
last ACTION;
};
/^PAP/ && do {
$menu = ispauth( "PAP", $menu );
last ACTION;
};
/^CHAP/ && do {
$menu = ispauth( "CHAP", $menu );
last ACTION;
};
/^Chat/ && do {
$menu = ispauth( "Chat", $menu );
last ACTION;
};
/^Nameservers/ && do {
$menu = getnameservers( $menu );
last ACTION;
};
/^Add-User/ && do {
$menu = add_user( $menu );
last ACTION;
};
/^ISPConnect/ && do {
$menu = ispconnect( $menu );
last ACTION;
};
/^Pre-Login/ && do {
$menu = prelogin( $menu );
last ACTION;
};
/^ISPLogin/ && do {
$menu = isplogin( $menu );
last ACTION;
};
/^ISPPrompt/ && do {
$menu = ispprompt( $menu );
last ACTION;
};
/^Post-Login/ && do {
$menu = postlogin( $menu );
last ACTION;
};
/^Password/ && do {
$menu = isppassword( $menu );
last ACTION;
};
/^Com/ && do {
$menu = ispport( $menu );
last ACTION;
};
/^Defaultroute/ && do {
$menu = defaultroute( $menu );
last ACTION;
};
/^Ipdefault/ && do {
$menu = ipdefault( $menu );
last ACTION;
};
/^Speed/ && do {
$menu = ispspeed( $menu );
last ACTION;
};
/^User/ && do {
$menu = ispname( $menu );
last ACTION;
};
/^Number/ && do {
$menu = ispnumber( $menu );
last ACTION;
};
/^Modeminit/ && do {
$menu = modeminit( $menu );
last ACTION;
};
/^Finished/ && do {
$menu = finish( $menu );
last ACTION;
};
/^Create/ && do {
$menu = newConnection( $menu );
last ACTION;
};
/^Delete/ && do {
$menu = deleteconnection( $menu );
last ACTION;
};
/^Debug/ && do {
$menu = debug( $menu );
last ACTION;
};
/^Demand/ && do {
$menu = demand( $menu );
last ACTION;
};
/^Persist/ && do {
$menu = persist( $menu );
last ACTION;
};
/^Remotename/ && do {
$menu = remotename( $menu );
last ACTION;
};
/^Idle-timeout/ && do {
$menu = idle_timeout( $menu );
last ACTION;
};
/^Quit/ && do {
$menu = quit( $menu );
last ACTION;
};
/.*/ && do {
die (sprintf(gettext("Internal error: no such thing as %s, "), $action));
};
}
} # End of while(1)
} # End of do_action
sub ispconnect($) { # the connection string sent by the modem
$temp=inputbox(gettext("Enter the text of connect acknowledgement, if any. This string will be sent when the CONNECT string is received from the modem. Unless you know for sure that your ISP requires such an acknowledgement you should leave this as a null string: that is, \'\'.\
"), gettext("Ack String"), "$$ispconnect" );
return "CANCEL" if( $result != 0 );
return $_[0] if $$ispconnect eq $temp;
$$ispconnect=$temp;
return $_[0];
}
sub isplogin($) { # the login prompt string sent by the ISP
$temp=inputbox(gettext("Enter the text of the login prompt. Chat will send your username in response. The most common prompts are login: and username:. Sometimes the first letter is capitalized and so we leave it off and match the rest of the word. Sometimes the colon is omitted. If you aren\'t sure, try ogin:."),
gettext("Login Prompt"), "$$isplogin" );
return "CANCEL" if( $result != 0 );
return $_[0] if $$isplogin eq $temp;
$$isplogin=$temp;
return $_[0];
}
sub ispprompt($) { # password prompt sent by the ISP
$temp=inputbox(gettext("Enter the text of the password prompt. Chat will send your password in response. The most common prompt is password:. Sometimes the first letter is capitalized and so we leave it off and match the last part of the word."), gettext("Password Prompt"), "$$ispprompt" );
return "CANCEL" if( $result != 0 );
return $_[0] if $$ispprompt eq $temp;
$$ispprompt=$temp;
return $_[0];
}
sub prelogin($) { # optional pre-login chat
$temp = inputbox(gettext("You probably do not need to put anything here. Enter any additional input your isp requires before you log in. If you need to make an entry, make the first entry the prompt you expect and the second the required response. Example: your isp sends \'Server:\' and expect you to respond with \'trilobite\'. You would put \'erver trilobite\' (without the quotes) here. All entries must be separated by white space. You can have more than one expect-send pair."), gettext("Pre-Login"), "$$prelogin" );
return "CANCEL" if( $result != 0 );
return $_[0] if $$prelogin eq $temp;
$$prelogin=$temp;
return $_[0];
}
sub postlogin($) { # post-login chat
$temp = inputbox(gettext("You probably do not need to change this. It is initially \'\' \\d\\c which tells chat to expect nothing, wait one second, and send nothing. This gives your isp time to get ppp started. If your isp requires any additional input after you have logged in you should put it here. This may be a program name like ppp as a response to a menu prompt. If you need to make an entry, make the first entry the prompt you expect and the second the required response. Example: your isp sends \'Protocol\' and expect you to respond with \'ppp\'. You would put \'otocol ppp\' (without the quotes) here. Fields must be separated by white space. You can have more than one expect-send pair."), gettext("Post-Login"), "$$postlogin" );
return "CANCEL" if( $result != 0 );
return $_[0] if $$postlogin eq $temp;
$$postlogin=$temp;
return $_[0];
}
sub do_ops($) {
my $temp;
$temp = ispname($_[0]);
return "CANCEL" if $temp eq "CANCEL";
$temp = isppassword($_[0]);
return "CANCEL" if $temp eq "CANCEL";
$temp = ispspeed($_[0]);
return "CANCEL"if $temp eq "CANCEL";
$temp = ispnumber($_[0]);
return "CANCEL" if $temp eq "CANCEL";
$temp = ispport($_[0]);
return $temp;
}
sub ispname($) { # input the user name for the ppp account
ISPNAME: $d = chatescape("UNDO", $$ispname);
$temp=inputbox (gettext("Enter the username given to you by your ISP."),
gettext("User Name"), "$d");
return "CANCEL" if ( $result != 0 );
return $_[0] if $d eq $temp;
if ($temp) {
$$ispname = chatescape("DO", $temp);
}
else {
goto ISPNAME if (uc($$ispauth) ne "CHAT");
$$ispname = '""';
}
$$user_arg=$$ispname;
return $_[0];
}
sub ispport($) { # identify the port the modem is on
my (@ttys, $manual, $tty, $port, $lines, @array, $temp);
my $good = 0;
yesnobox(gettext("Answer \'yes\' to have the port your modem is on identified automatically. It will take several seconds to test each serial port. Answer \'no\' if you would rather enter the serial port yourself"),
gettext("Choose Modem Config Method"));
if (! $result) { # true $result means no.
if (!system("pidof", "pppd")) {
msgbox(gettext("Can\'t probe while pppd is running."));
@array = (gettext("Below is a list of all the serial ports that appear to have hardware that can be used for ppp. One that seems to have a modem on it has been preselected. If no modem was found \'Manual\' was preselected. To accept the preselection just hit TAB and then ENTER. Use the up and down arrow keys to move among the selections, and press the spacebar to select one. When you are finished, use TAB to select <OK> and ENTER to move on to the next item. "), gettext("Select Modem Port"), $lines);
push @array, @ttys;
push @array, "Manual", gettext("Enter the port by hand. "), $manual;
$temp = radiolist @array;
return "CANCEL" if ( $result != 0 ) ;
if ($temp ne "Manual") {
$$ispport = $temp;
return $_[0];
}
}
MANUAL: $temp=inputbox (gettext("Enter the port your modem is on. \
/dev/ttyS0 is COM1 in DOS. \
/dev/ttyS1 is COM2 in DOS. \
/dev/ttyS2 is COM3 in DOS. \
/dev/ttyS3 is COM4 in DOS. \
/dev/ttyS1 is the most common. Note that this must be typed exactly as shown. Capitalization is important: ttyS1 is not the same as ttys1."),
$temp=radiolist (gettext("Enabling default routing tells your system that the way to reach hosts to which it is not directly connected is via your ISP. This is almost certainly what you want. Use the up and down arrow keys to move among the selections, and press the spacebar to select one. When you are finished, use TAB to select <OK> and ENTER to move on to the next item."),
$temp=inputbox (gettext("You almost certainly do not want to change this from the default value of noipdefault. This not the place for your nameserver ip numbers. It is the place for your ip number if and only if your ISP has assigned you a static one. If you have been given only a local static ip, enter it with a colon at the end, like this: 192.168.1.2: If you have been given both a local and a remote ip, enter the local ip, a colon, and the remote ip, like this: 192.168.1.2:10.203.1.2 "),
gettext("IP Numbers"), "$$ipdefault");
return "CANCEL" if ( $result != 0 );
$$ipdefault = $temp;
return $_[0];
}
sub ispspeed($) { # get the port speed
$temp=inputbox (gettext("Enter your modem port speed (e.g. 9600, 19200, 38400, 57600, 115200). I suggest that you leave it at 115200."),
gettext("Speed"), "$$ispspeed");
return "CANCEL" if ( $result != 0 );
$$ispspeed = $temp;
return $_[0];
}
sub modeminit($) {
$tempmodeminit = chatescape("UNDO", $$modeminit);
$temp=inputbox (gettext("Enter modem initialization string. The default value is ATZ, which tells the modem to use it\'s default settings. As most modems are shipped from the factory with default settings that are appropriate for ppp, I suggest you not change this."),
$temp=radiolist (gettext("Select method of dialing. Since almost everyone has touch-tone, you should leave the dialing method set to tone unless you are sure you need pulse. Use the up and down arrow keys to move among the selections, and press the spacebar to select one. When you are finished, use TAB to select <OK> and ENTER to move on to the next item."),
gettext("Pulse or Tone"), 2,
"Tone", "", $tone,
"Pulse", "", $pulse);
return "CANCEL" if ( $result != 0 );
$tempatdx =~ s/dp/DT/i if ($temp eq "Tone" && $pulse);
$tempatdx =~ s/dt/DP/i if ($temp eq "Pulse" && $tone);
# Now get the number.
$tempnumber = inputbox (gettext("Enter the number to dial. Don\'t include any dashes. See your modem manual if you need to do anything unusual like dialing through a PBX."),
gettext("Phone Number"), "$number");
return "CANCEL" if ( $result != 0 );
return $_[0] if ($number eq $tempnumber && $atdx eq $tempatdx);
$temp = $tempatdx . $tempnumber;
$$ispnumber = chatescape("DO", $temp);
return $_[0];
}
sub isppassword($) {
ISPWORD: $d = $$isppassword;
$d = chatescape("UNDO", $d);
$d =~ s/^\\q//;
$temp = inputbox (gettext("Enter the password your ISP gave you."),
gettext("Password"),
"$d");
return "CANCEL" if ( $result != 0 );
return $_[0] if $temp eq $d;
# Add enclosing quotes and a \q to keep the password out of the log if we are using chat.
$temp=inputbox(gettext("Enter the name you wish to use to refer to this isp. You will probably want to give the default name of \'provider\' to your primary isp. That way, you can dial it by just giving the command \'pon\'. Give each additional isp a unique name. For example, you might call your employer \'theoffice\' and your university \'theschool\'. Then you can connect to your isp with \'pon\', your office with \'pon theoffice\', and your university with \'pon theschool\'. Note: the name must contain no spaces."),
gettext("Provider Name"), "$temp" );
return "CANCEL" if( $result != 0 );
};
if (do_files ( "test", $temp )) {
noyesbox (gettext("This connection exists. Do you want to overwrite it?"),
gettext("Connection Exists"));
goto getname if( $result ); # true $result means no so go back to getname.
}
$provider = $temp;
$$remotename_arg = $provider if $$remotename;
$$ipparam_arg = $provider if $$ipparam;
return $temp;
}
sub finish($) {
# this is to tidy up things with the user and is in no way
# associated with any Finnish Connections ;)
my $temp;
msgbox(sprintf(gettext("Finished configuring connection and writing changed files. The chat strings for connecting to the ISP are in /etc/chatscripts/%s, while the options for pppd are in /etc/ppp/peers/%s. You may edit these files by hand if you wish. You will now have an opportunity to exit the program, configure another connection, or revise this or another one."), $provider, $provider),
gettext("Finished"));
$result = 0;
if ($provider) {
do_files( "put", $provider );
unlink "$pppconfig_dir/$provider";
}
foreach $temp (@deletelist) {
# next if $temp eq $provider; # Don't delete the new provider by accident. Disabled. JGH
do_files("get", $temp);
secrets_file("delete", $temp, $$ispauth) if(lc($$ispauth) ne "chat");
if (grep (/\.bak$/, $temp)) { # Let him delete backups. Avoid Swedish chef effect.
noyesbox (gettext("Do you wish to quit without saving your changes?"), gettext("Quit"));
if( $result ) {
# true $result means no so go back to menu.
return $_[0];
}
}
# system(clear);
exit(0);
}
sub debug($) {
$a = $$debugcmd ? gettext("Debugging is presently enabled.") : gettext("Debugging is presently disabled.");
yesnobox(sprintf(gettext("Selecting YES will enable debugging. Selecting NO will disable it. %s"), $a), gettext("Debug Command"));
if( $result ) { # true $result means no.
$$debugcmd = '';
$$connectcmd =~ s/chat +-v/chat/;
}
else {
$$debugcmd = "debug";
$$connectcmd =~ s/chat/chat -v/ if $$connectcmd !~ /chat +-v/;
}
return $_[0];
}
sub demand($) {
$a = $$demand ? "enabled" : "disabled";
yesnobox(sprintf(gettext("Selecting YES will enable demand dialing for this provider. Selecting NO will disable it. Note that you will still need to start pppd with pon: pppconfig will not do that for you. When you do so, pppd will go into the background and wait for you to attempt access something on the Net, and then dial up the ISP. If you do enable demand dialing you will also want to set an idle-timeout so that the link will go down when it is idle. Demand dialing is presently %s."), $a), gettext("Demand Command"));
if( $result ) { # true $result means no.
$$demand = '';
}
else {
$$demand = "demand";
$$persist = '';
}
return $_[0];
}
sub persist($) {
$a = $$persist ? "enabled" : "disabled";
yesnobox(sprintf(gettext("Selecting YES will enable persist mode. Selecting NO will disable it. This will cause pppd to keep trying until it connects and to try to reconnect if the connection goes down. Persist is incompatible with demand dialing: enabling demand will disable persist. Persist is presently %s."), $a), gettext("Persist Command"));
if( $result ) { # true $result means no.
$$persist = '';
}
else {
$$persist = "persist";
}
return $_[0];
}
# Get the nameservers.
# resolv_conf is initialized to "OK".
sub getnameservers($) {
my ($a, $b, $c);
$a = $b = $c = "off";
if ($$usepeerdns eq "usepeerdns") {
$dns = "dynamic"; $b = "on";
}
elsif ($$ipparam eq "ipparam") {
$dns = "static"; $a = "on";
}
else {
$dns = "none"; $c = "on";
}
my $method = radiolist(gettext("Choose a method. \'Static\' means that the same nameservers will be used every time this provider is used. You will be asked for the nameserver numbers in the next screen. 'Dynamic' means that pppd will automatically get the nameserver numbers each time you connect to this provider. 'None' means that DNS will be handled by other means, such as BIND (named) or manual editing of /etc/resolv.conf. Select 'None' if you do not want /etc/resolv.conf to be changed when you connect to this provider. Use the up and down arrow keys to move among the selections, and press the spacebar to select one. When you are finished, use TAB to select <OK> and ENTER to move on to the next item."),
gettext("Configure Nameservers (DNS)") , 3,
"Static", gettext("Use static DNS"), $a,
"Dynamic", gettext("Use dynamic DNS"), $b,
"None", gettext("DNS will be handled by other means"), $c );
return "CANCEL" if( $result != 0 );
SWITCH: for( $method ) {
/Static/ && do {
my $ipnumber = inputbox(gettext("\
Enter the IP number for your primary nameserver."), gettext("IP number"), '' );
return "CANCEL" if( $result );
# true $result means CANCEL so go back to main menu.
$NAMESERVER1 = "nameserver ".$ipnumber."\n" if $ipnumber;
$$usepeerdns = "";
$$ipparam = "ipparam";
$$ipparam_arg = $provider;
$dns = "static";
$resolv_conf="SAVE";
$ipnumber = inputbox(gettext("Enter the IP number for your secondary nameserver (if any)."), gettext("IP number"), '' );
return "CANCEL" if( $result );
$NAMESERVER2 = "nameserver ".$ipnumber."\n" if $ipnumber;
return $_[0];
last SWITCH;
};
/Dynamic/ && do {
$$usepeerdns = "usepeerdns";
$NAMESERVER1 = "";
$NAMESERVER2 = "";
$resolv_conf="SAVE";
$$ipparam = "ipparam";
$$ipparam_arg = $provider;
$dns = "dynamic";
return $_[0];
last SWITCH;
};
/None/ && do {
$$usepeerdns = "";
$$ipparam = "";
$$ipparam_arg = "";
$resolv_conf="OK";
$dns = "none";
return $_[0];
last SWITCH;
};
}
}
sub add_user($) {
LOOP: $temp=inputbox (gettext("Enter the username of a user who you want to be able to start and stop ppp. She will be able to start any connection. To remove a user run the program vigr and remove the user from the dip group. "),
gettext("Add User "), "\"\"");
return "CANCEL" if ( $result != 0 );
unless (getpwnam $temp) { # Make sure the user exists.
msgbox (sprintf(gettext("\
No such user as %s. "), $temp));
goto LOOP;
}
push @newuserlist, $temp;
return $_[0];
}
sub adduser($) { # Called from finish() to actually add the user.
`adduser --quiet @_[0] dip`;
}
sub remotename($) {
$temp=inputbox(gettext("You probably don't want to change this. Pppd uses the remotename as well as the username to find the right password in the secrets file. The default remotename is the provider name. This allows you to use the same username with different providers. To disable the remotename option give a blank remotename. The remotename option will be omitted from the provider file and a line with a * instead of a remotename will be put in the secrets file."), gettext("Remotename"), "$$remotename_arg");
$temp=inputbox(gettext("If you want this PPP link to shut down automatically when it has been idle for a certain number of seconds, put that number here. Leave this blank if you want no idle shutdown at all."), gettext("Idle Timeout"), "$$idle_arg");
return "CANCEL" if( $result != 0 );
$$idle_arg = $temp =~ /\w+/ ? $temp : "";;
$$idle = $$idle_arg ? "idle" : "";
return $_[0];
}
sub putnameservers() {
# Fix up resolv.conf if needed.
return if( $resolv_conf eq "OK" );
open( RESOLV, ">$pppresolv/$provider" ) or die(sprintf(gettext("Couldn\'t open %s.\n"), "$pppresolv/$provider"));